package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.Announcement;
import com.itheima.mapper.AnnouncementMapper;
import com.itheima.service.db.AnnouncementService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class AnnouncementServiceImpl implements AnnouncementService {
    @Autowired
    private AnnouncementMapper announcementMapper;

    //公告列表
    public PageBeanVo announcementList(Integer pageNum, Integer pageSize) {
        //创建page对象
        IPage<Announcement> page = new Page(pageNum, pageSize);
        //创建查询条件
        QueryWrapper<Announcement> wrapper = new QueryWrapper();
        //进行条件查询
        page = announcementMapper.selectPage(page, wrapper);
        //返回数据pageBeanVo
        return new PageBeanVo(pageNum, pageSize, page.getTotal(), page.getRecords());
    }
}
